// 遍历赋值
export function extend(o, n) {
  const obj = Object.assign({}, o)
  for (var p in obj) {
    if (obj.hasOwnProperty(p)) {
      obj[p] = n[p]
    }
  }
  return obj
}

// 删除
export function delUtil(url, params, alterMsg) {
  if (!url) {
    console.error('url not empty')
  }
  return new Promise((resolve, reject) => {
    this.$confirm(alterMsg || '此操作将永久删除该数据, 是否继续?', '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    }).then(() => {
      this.$http.delete(url, {params}).then((res) => {
        if (res.status === 0) {
          this.$notify.success({
            title: '成功',
            message: '删除成功！'
          })
          resolve(res)
        } else if (res.status === 1) {
          this.$notify.error({
            title: '失败',
            message: '删除失败！'
          })
          reject(res)
        }
      })
    }).catch(() => {
    })
  })
}
